package com.java.huxb.backend.zuul.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;

import javax.servlet.http.HttpServletRequest;

/**
 * @author huxb
 * @date 2020/1/31 0031 上午 11:09
 */
public class PersonFilter extends ZuulFilter {
    @Override
    public String filterType() {
        return "pre";
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        //线程安全的
        RequestContext requestContext = RequestContext.getCurrentContext();

        HttpServletRequest request = requestContext.getRequest();

        String queryString = request.getQueryString();

        System.out.println(queryString);

        requestContext.getResponse();

        System.out.println("pre filter ");
        return null;
    }
}
